﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_ACEIndex.cshtml";
}

@this.Partial("Index-js")
<script>
    var actionList = @this.Raw(this.ViewBag.ActionListString)
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$ace.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <button class="btn btn-primary" data-bind="click:Edit,attr:{disabled:!DataTable.SelectedModel()}"><i class="fa fa-pencil-square-o"></i>修改</button>
            <button class="btn btn-primary" data-bind="click:Delete,attr:{disabled:!DataTable.SelectedModel()}"><i class="fa fa-trash-o"></i>删除</button>
            <button class="btn btn-primary" data-bind="click:Add"><i class="fa fa-plus"></i>添加</button> 
            <button class="btn btn-primary" data-bind="click:Detail,attr:{disabled:!DataTable.SelectedModel()}"><i class="fa fa-pencil-square-o"></i>详情</button>          
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="名称/编号" style="width: 200px;" data-bind="value:SearchModel().keyword">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary" data-bind="click:Search"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>


<div class="table-responsive">
    <table class="table table-hover" data-bind="with:DataTable">
        <thead>
            <tr>
                <th style="width:20px;"></th>
                <th>名称</th>
                <th>编号</th>
                <th>控制器名</th>
                @*<th>链接</th>*@
                <th>描述</th>
                <th>类型</th>
                <th>上级</th>
            </tr>
        </thead>

        <tbody data-bind="foreach:Models">
            <tr data-bind="click:$parent.SelectRow">
                <td data-bind="text:$parent.GetOrdinal($index())"></td>
                <td data-bind="text:id" hidden></td>
                <td data-bind="text:actionname"></td>
                <td data-bind="text:actioncode" ></td>
                <td data-bind="text:controlername"></td>
                <td data-bind="text:actionurl" hidden></td>
                <td data-bind="text:actiondescription" ></td>
                <td data-bind="text:actiontype" ></td>
                @*<td data-bind="text:$ace.getFuzzyContent(actionparam()),attr:{herf:'#',title:actionparam}" hidden></td>*@
                <td data-bind="text:$ace.getOptionTextByValue(actionList,actionowner())"></td>                
            </tr>
        </tbody>
        @this.Partial("_tfoot")
    </table>
</div>

@using (Html.Dialog())
{

    <form id="form1">
        <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
            <div class="alert alert-danger" style="text-align: left; margin-bottom: 10px;">
                        <i class="fa fa-warning alert-dismissible" style="position: relative; top: 1px; font-size: 15px; padding-right: 5px;"></i>
                        动作类型请填写0/1/2，0为控制器动作，1为普通动作，2为工作流动作
                    </div>
            <div style="padding-top: 20px; margin-right: 30px;">
                
                <table class="form"> 
                    <tr>
                        <td class="formTitle">名称<span style="color:red;">*</span></td>
                        <td class="formValue">
                            <input id="actionname" name="actionname" type="text" class="form-control required" data-bind="value:Model().actionname" />
                        </td>
                        <td class="formTitle">控制器名<span style="color:red;">*</span></td>
                        <td class="formValue">
                            <input id="controlername" name="controlername" type="text" class="form-control required" data-bind="value:Model().controlername" />
                        </td>                 
                    </tr>
                    <tr>
                         <td class="formTitle">编号:</td>
                        <td class="formValue">
                            <input id="actioncode" name="actioncode" type="text" class="form-control " data-bind="value:Model().actioncode" />
                        </td>
                          <td class="formTitle">动作类型：</td>
                        <td class="formValue">
                            <input id="actiontype" name="actiontype" type="text" class="form-control" data-bind="value:Model().actiontype" />
                        </td>  
                    </tr>
                     <tr>
                          <td class="formTitle">描述</td>
                        <td class="formValue">
                            <input id="actiondescription" name="actiondescription" type="text" class="form-control" data-bind="value:Model().actiondescription" />
                        </td>   
                         <td class="formTitle">上级：</td>
                        <td class="formValue">
                            <input id="actionowner" name="actionowner" type="text" class="form-control " data-bind="value:Model().actionowner" />
                        </td>   
                                                            
                    </tr>
                    <tr>
                       <td class="formTitle">动作链接：</td>
                        <td class="formValue">
                          <input id="actionurl" name="actionurl" type="text" class="form-control" data-bind="value:Model().actionurl" />    
                        </td> 
                          <td class="formTitle">动作相关参数：</td>
                        <td class="formValue">
                            <input id="actionparam" name="actionparam" type="text" class="form-control" data-bind="value:Model().actionparam" />
                        </td>      
                    </tr>

                </table>
            </div>
        </div>
    </form>
}
@using (Html.Dialog("DetailDialog", "DetailDialog", 800))
{
    <form id="DetailForm">
        <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
            <div style="padding-top: 20px; margin-right: 30px;">
                <table class="form">
                    <tr>
                        <td class="formTitle">名称：</td>
                        <td class="formValue">                            
                            <label class="form-control" data-bind="text:Model().actionname"></label>
                        </td>
                        <td class="formTitle">控制器名：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().controlername"></label>
                        </td>
                    </tr>
                    <tr>
                         <td class="formTitle">描述：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().actiondescription"></label>
                        </td>
                         <td class="formTitle">编号：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().actioncode"></label>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">上级：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:  $ace.getOptionTextByValue(actionList,Model().actionowner)"></label>
                        </td>
                        <td class="formTitle">动作类型：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().actiontype"></label>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">动作链接：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().actionurl"></label>
                        </td>
                        <td class="formTitle">动作相关参数：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().actionparam"></label>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>
}
